Example 3 :LCD Screen

Code


/*In this simulation we will test the LCD screen that is built into the center of the motherboard of the robot*/

/*We include the appropriate libraries to be able to activate certain commands and instructions*/

#include <Wire.h>
#include <Zumo32U4.h>

/*On the other hand, this code is only valid for the Zumo 32U4 OLED variant, as the other variant contains a different type of screen and needs other instructions*/

/*In the following line we name the component of the robot that will be used*/

Zumo32U4OLED display;

/*In the void setup section it is not necessary to add anything since in the circuit we do not have to assign pins, outputs, inputs, etc*/

void setup()
{

}

/*In the void loop section is where we will give the instructions and texts we want to appear on the screen*/

void loop()
{

/*First we delete what was already on the screen before*/
  
  display.clear();

/*Then we create a first line, in which we will put the text "Hello" in parentheses*/
  
  display.print("Hello");

/*Then we have to indicate that we move to the second line, putting a 0 and a 1, corresponding to the line 1 and 2*/
  
  display.gotoXY(0, 1);

/*As we did before, we put the text in parentheses with the print function, in this case we will put "User"*/
  
  display.print("User");

/*Now we put a delay of one second, before another text appears*/

  delay(3000);

/*We delete the text again*/
  
  display.clear();

/*We write another text in the first line*/
  
  display.print("How are");

/*We go to the second line*/
  
  display.gotoXY(0, 1);

/*We write another text in the second line*/
  
  display.print("you???");

/*And finally we put in another three second delay before the first text reappears*/

  delay(3000);

}

Video of the Circuit